var productId = getQuery("productId");
window.onload =function (){

    showProduct();
}
function showLoginInfo(){
    axios.get("/user/getLoginUser",null).then(e=>{
        var info = e.data;
        if (info ==null || info==''){
            location.href="/login.html?loginError=noCustom"
        }

    })
}
async function addProduct(){
    showProduct();
   await axios.get("/custom/shop/buy",{
        params:{
            productId,
        }
    }).then(e=>{
        if (e.data =="ok"){
            location.href="/index.html";
        }else {
            location.href="/login.html?loginError=noCustom"
        }

    })
}
function showProduct(){
    axios.get("/product/findById",{
        params:{
            productId
        }
    }).then(e=>{
        var info = e.data;
        $("id").innerHTML=info.id;
        $("name").innerHTML=info.name;
        $("price").innerHTML=info.price;
        $("address").innerHTML=info.address;
        $("createDate").innerHTML=info.createDate;
        $("num").innerHTML=info.num;
        $("imgPath").src = "/productImage/" +info.imgPath;
    })
}function returnIndex(){
    location.href="/index.html";
}